﻿Ext.data.validations = {


    presenceMessage: 'must be present',


    lengthMessage: 'is the wrong length',


    formatMessage: 'is the wrong format',


    inclusionMessage: 'is not included in the list of acceptable values',


    exclusionMessage: 'is not an acceptable value',


    presence: function (config, value) {
        if (value == undefined) {
            value = config;
        }

        return !!value;
    },


    length: function (config, value) {
        if (value == undefined) {
            return false;
        }

        var length = value.length,
            min = config.min,
            max = config.max;

        if ((min && length < min) || (max && length > max)) {
            return false;
        } else {
            return true;
        }
    },


    format: function (config, value) {
        return !!(config.matcher && config.matcher.test(value));
    },


    inclusion: function (config, value) {
        return config.list && config.list.indexOf(value) != -1;
    },


    exclusion: function (config, value) {
        return config.list && config.list.indexOf(value) == -1;
    }
};